<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Post\Controller;
class EmailController extends \Member\Controller\IndexController {

	//邮箱认证------------------------------------------------------------------------------------/
	//2.邮箱认证发送验证码
	//地址 /post/email/sendcode
	public function sendcodeAction(){
		if(intval($_GET['email'])){
			//移动
		}else{
			if(IsPost('Submit')){
				$change=$_POST['change']==1 ? 1 : 0;
				$resend=$_GET['resend']==1 ? 1 : 0;
				$certificate = new \MemberCertificate\Model\MemberCertificateModel();
				if($id=$certificate->SendCode('email',$resend)){
					$this->ajaxReturn(array('title'=>'发送成功','message'=>$certificate->getSuccess(),'status'=>'ok','refresh'=>true,'url'=>U('/member/email/verify/change/'.$change.'/id/'.$id),$_POST['datatype']));
				}else{
					$this->ajaxReturn(array('title'=>'发送失败','message'=>$certificate->getError(),'status'=>'error',$_POST['datatype']));
				}
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>'没有数据提交！'.$result,'status'=>'error'),$_POST['datatype']);
			}
		}
	}
	
	//4.检查用户验证码
	//地址 /post/email/verify
	public function verifyAction(){
		if(intval($_GET['email'])){
			//移动
		}else{
			if(IsPost('Submit')){
				$change=$_POST['change']==1 ? 1 : 0;
				//是否认证过了
				$certificate = new \MemberCertificate\Model\MemberCertificateModel();
				
				if($certificate->VerifyCode('email')){
					if($change){
						$url=U('/member/email');
					}else{
						$url=U('/member/email/success');
					}
					$this->ajaxReturn(array('title'=>'验证成功','message'=>$certificate->getSuccess(),'status'=>'ok','refresh'=>true,'url'=>$url,$_POST['datatype']));
				}else{
					$this->ajaxReturn(array('title'=>'发送失败','message'=>$certificate->getError(),'status'=>'error',$_POST['datatype']));
				}
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>'没有数据提交！'.$result,'status'=>'error'),$_POST['datatype']);
			}
		}
	}
	
	
	//邮箱认证------------------------------------------------------------------------------------ end/

}